﻿using Dapper;
using IRealize;
using Microsoft.Data.SqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Realize
{
    public class RJ : IRJ
    {
        public async Task<int> Add_RJ(List<int> list, string id, string sqlserver)
        {
            using (SqlConnection connection = new SqlConnection(sqlserver))
            {
                string sql = $@"delete from RolesJurisdiction where RolesID = '{id}'";
                int result = await connection.ExecuteAsync(sql);
                foreach (int i in list)
                {
                    sql = $@"insert into RolesJurisdiction values('{id}','{i}')";
                    result = await connection.ExecuteAsync(sql);
                }
                return result;
            }
        }
    }
}
